//
//  LogisticsModel.swift
//
//  Created by 邱仙凯 on 2021/6/10
//  Copyright (c) . All rights reserved.
//

import Foundation
import ObjectMapper

public struct ZyaLogisticsModel: Mappable {

  // MARK: Declaration for string constants to be used to decode and also serialize.
  private struct SerializationKeys {
    static let zProvinceFh = "z_province_fh"
    static let zProvinceSh = "z_province_sh"
    static let zLogisticsNm = "z_logistics_nm"
    static let zDistrictFh = "z_district_fh"
    static let zConsignerNm = "z_consigner_nm"
    static let zConsigneeAddress = "z_consignee_address"
    static let zCreateTm = "z_create_tm"
    static let zConsigneeNm = "z_consignee_nm"
    static let zContractId = "z_contract_id"
    static let zOrgNm = "z_org_nm"
    static let idKey = "id_key"
    static let zOrgId = "z_org_id"
    static let zType = "z_type"
    static let zConsignerDate = "z_consigner_date"
    static let rn = "rn"
    static let zCityFh = "z_city_fh"
    static let zStaffNm = "z_staff_nm"
    static let zCitySh = "z_city_sh"
    static let zConsigneeTel = "z_consignee_tel"
    static let zSupplierNm = "z_supplier_nm"
    static let zSupplierId = "z_supplier_id"
    static let zConsignerTel = "z_consigner_tel"
    static let zConsignerAddress = "z_consigner_address"
    static let zStaffId = "z_staff_id"
    static let zDistrictSh = "z_district_sh"
    static let zContractNo = "z_contract_no"
    static let zStatus = "z_status"
    static let zLogisticsNo = "z_logistics_no"
    static let detail = "detail"
    static let ztbFileUrl = "ztb_file_url"
    static let zDeliveryType = "z_delivery_type"
      static let zSignDate = "z_sign_date"
      static let zPayAmount = "z_pay_amount"
      static let zPaydAmount = "z_payd_amount"
      static let zAccPeriod = "z_account_period"
      static let zRemianPeriod = "z_remian_period"
  }

  // MARK: Properties
  public var zProvinceFh: String?
  public var zProvinceSh: String?
  public var zLogisticsNm: String?
  public var zDistrictFh: String?
  public var zConsignerNm: String?
  public var zConsigneeAddress: String?
  public var zCreateTm: String?
  public var zConsigneeNm: String?
  public var zContractId: Int?
  public var zOrgNm: String?
  public var idKey: String?
  public var zOrgId: Int?
  public var zType: String?
  public var zConsignerDate: String?
  public var rn: Int?
  public var zCityFh: String?
  public var zStaffNm: String?
  public var zCitySh: String?
  public var zConsigneeTel: String?
  public var zSupplierNm: String?
  public var zSupplierId: Int?
  public var zConsignerTel: String?
  public var zConsignerAddress: String?
  public var zStaffId: String?
  public var zDistrictSh: String?
  public var zContractNo: String?
  public var zStatus: String?
  public var zLogisticsNo: String?
    public var detail: [ZyaLogisticsDetail]?
    public var ztbFileUrl: String?
    public var zDeliveryType: String?
    public var zSignDate: String?
    public var zPayAmount: String?
    public var zPaydAmount: String?
    public var zAccPeriod: Int?
    public var zRemianPeriod: Int?
  
  // MARK: ObjectMapper Initializers
  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public init?(map: Map){

  }

  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public mutating func mapping(map: Map) {
    zProvinceFh <- map[SerializationKeys.zProvinceFh]
    zProvinceSh <- map[SerializationKeys.zProvinceSh]
    zLogisticsNm <- map[SerializationKeys.zLogisticsNm]
    zDistrictFh <- map[SerializationKeys.zDistrictFh]
    zConsignerNm <- map[SerializationKeys.zConsignerNm]
    zConsigneeAddress <- map[SerializationKeys.zConsigneeAddress]
    zCreateTm <- map[SerializationKeys.zCreateTm]
    zConsigneeNm <- map[SerializationKeys.zConsigneeNm]
    zContractId <- map[SerializationKeys.zContractId]
    zOrgNm <- map[SerializationKeys.zOrgNm]
    idKey <- (map[SerializationKeys.idKey],StringTransform())
    zOrgId <- map[SerializationKeys.zOrgId]
    zType <- map[SerializationKeys.zType]
    zConsignerDate <- map[SerializationKeys.zConsignerDate]
    rn <- map[SerializationKeys.rn]
    zCityFh <- map[SerializationKeys.zCityFh]
    zStaffNm <- map[SerializationKeys.zStaffNm]
    zCitySh <- map[SerializationKeys.zCitySh]
    zConsigneeTel <- map[SerializationKeys.zConsigneeTel]
    zSupplierNm <- map[SerializationKeys.zSupplierNm]
    zSupplierId <- map[SerializationKeys.zSupplierId]
    zConsignerTel <- map[SerializationKeys.zConsignerTel]
    zConsignerAddress <- map[SerializationKeys.zConsignerAddress]
    zStaffId <- (map[SerializationKeys.zStaffId],StringTransform())
    zDistrictSh <- map[SerializationKeys.zDistrictSh]
    zContractNo <- map[SerializationKeys.zContractNo]
    zStatus <- (map[SerializationKeys.zStatus],StringTransform())
    zLogisticsNo <- map[SerializationKeys.zLogisticsNo]
    detail <- map[SerializationKeys.detail]
    ztbFileUrl <- map[SerializationKeys.ztbFileUrl]
    zDeliveryType <- (map[SerializationKeys.zDeliveryType],StringTransform())
      
      zSignDate <- map[SerializationKeys.zSignDate]
      zPayAmount <- (map[SerializationKeys.zPayAmount],StringTransform_test())
      zPaydAmount <- (map[SerializationKeys.zPaydAmount],StringTransform_test())
      zAccPeriod <- map[SerializationKeys.zAccPeriod]
      zRemianPeriod <- map[SerializationKeys.zRemianPeriod]
      
  }

  /// Generates description of the object in the form of a NSDictionary.
  ///
  /// - returns: A Key value pair containing all valid values in the object.
  public func dictionaryRepresentation() -> [String: Any] {
    var dictionary: [String: Any] = [:]
    if let value = zProvinceFh { dictionary[SerializationKeys.zProvinceFh] = value }
    if let value = zProvinceSh { dictionary[SerializationKeys.zProvinceSh] = value }
    if let value = zLogisticsNm { dictionary[SerializationKeys.zLogisticsNm] = value }
    if let value = zDistrictFh { dictionary[SerializationKeys.zDistrictFh] = value }
    if let value = zConsignerNm { dictionary[SerializationKeys.zConsignerNm] = value }
    if let value = zConsigneeAddress { dictionary[SerializationKeys.zConsigneeAddress] = value }
    if let value = zCreateTm { dictionary[SerializationKeys.zCreateTm] = value }
    if let value = zConsigneeNm { dictionary[SerializationKeys.zConsigneeNm] = value }
    if let value = zContractId { dictionary[SerializationKeys.zContractId] = value }
    if let value = zOrgNm { dictionary[SerializationKeys.zOrgNm] = value }
    if let value = idKey { dictionary[SerializationKeys.idKey] = value } else {
        dictionary[SerializationKeys.idKey] = ""
    }
    if let value = zOrgId { dictionary[SerializationKeys.zOrgId] = value }
    if let value = zType { dictionary[SerializationKeys.zType] = value }
    if let value = zConsignerDate { dictionary[SerializationKeys.zConsignerDate] = value }
    if let value = rn { dictionary[SerializationKeys.rn] = value }
    if let value = zCityFh { dictionary[SerializationKeys.zCityFh] = value }
    if let value = zStaffNm { dictionary[SerializationKeys.zStaffNm] = value }
    if let value = zCitySh { dictionary[SerializationKeys.zCitySh] = value }
    if let value = zConsigneeTel { dictionary[SerializationKeys.zConsigneeTel] = value }
    if let value = zSupplierNm { dictionary[SerializationKeys.zSupplierNm] = value }
    if let value = zSupplierId { dictionary[SerializationKeys.zSupplierId] = value }
    if let value = zConsignerTel { dictionary[SerializationKeys.zConsignerTel] = value }
    if let value = zConsignerAddress { dictionary[SerializationKeys.zConsignerAddress] = value }
    if let value = zStaffId { dictionary[SerializationKeys.zStaffId] = value }
    if let value = zDistrictSh { dictionary[SerializationKeys.zDistrictSh] = value }
    if let value = zContractNo { dictionary[SerializationKeys.zContractNo] = value }
    if let value = zStatus { dictionary[SerializationKeys.zStatus] = value }
    if let value = zLogisticsNo { dictionary[SerializationKeys.zLogisticsNo] = value }
    if let value = detail { dictionary[SerializationKeys.detail] = value.map { $0.dictionaryRepresentation() } }
    if let value = ztbFileUrl { dictionary[SerializationKeys.ztbFileUrl] = value }
    if let value = zDeliveryType { dictionary[SerializationKeys.zDeliveryType] = value }
      if let value = zSignDate { dictionary[SerializationKeys.zSignDate] = value }

      if let value = zPayAmount { dictionary[SerializationKeys.zPayAmount] = value }
      if let value = zPaydAmount { dictionary[SerializationKeys.zPaydAmount] = value }
      if let value = zAccPeriod { dictionary[SerializationKeys.zAccPeriod] = value }
      if let value = zRemianPeriod { dictionary[SerializationKeys.zRemianPeriod] = value }

    return dictionary
  }

}
